/*
 *接口编写处...
*如果接口需要做Action的权限验证，请在Action上使用属性
*如: [ApiActionPermission("Bas_Version",Enums.ActionPermissionOptions.Search)]
 */
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using DGZImp.BasProject.DomainModels;
using DGZImp.BasProject.IServices;
using DGZImp.Core.Utilities.Response;
using Microsoft.AspNetCore.Authorization;

namespace DGZImp.BasProject.Controllers
{
    public partial class Bas_VersionController
    {
        private readonly IBas_VersionService _service;//访问业务代码
        private readonly IHttpContextAccessor _httpContextAccessor;

        [ActivatorUtilitiesConstructor]
        public Bas_VersionController(
            IBas_VersionService service,
            IHttpContextAccessor httpContextAccessor
        )
        : base(service)
        {
            _service = service;
            _httpContextAccessor = httpContextAccessor;
        }

        /// <summary>
        /// 检查版本更新
        /// </summary>
        /// <param name="appId"></param>
        /// <param name="version"></param>
        /// <returns></returns>
        [HttpGet]
        [Route("checkUpdate")]

        public async Task<ApiResponse<object>> checkUpdate(string appId, string version)
        {
            var res = await _service.CheckAppVersionUpdate(appId, version);
            return ApiRes.Success(res);
        }


        /// <summary>
        /// 获取当前app的版本信息
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        [Route("GetCurApkPkg")]

        [AllowAnonymous]
        public async Task<ApiResponse<Bas_Version>> GetCurApkPkg()
        {
            var res = await _service.getCurApkPkg();
            return ApiRes.Success(res);
        }
    }
}
